package com.ztsoft.user.controller.project;

import com.ztsoft.user.pojo.entity.project.Contacts;
import com.ztsoft.user.pojo.vo.project.UnifiedForms;
import com.ztsoft.user.service.project.ContactsService;
import com.ztsoft.user.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@CrossOrigin("*")
@RestController
@RequestMapping("/contacts")
@Api(tags = "需求单位联系人控制层")
public class ContactsController {
    @Resource
    private ContactsService contactsService;

    @GetMapping("/getContactsByDemandUnitId")
    @ApiOperation(value = "根据需求单位查找联系人", notes = "根据需求单位查找联系人")
    public Result<Object> getContactsByDemandUnitId(String pDemandUnitId) {
        return contactsService.getContactsByDemandUnitId(pDemandUnitId);
    }

    @PutMapping("/updateContacts")
    @ApiOperation(value = "修改需求单位联系人", notes = "修改需求单位联系人")
    public Result<Object> updateContacts(@RequestBody Contacts contacts) {
        return contactsService.updateContacts(contacts);
    }

    @PostMapping("/addContacts")
    @ApiOperation(value = "添加需求单位联系人", notes = "添加需求单位联系人")
    public Result<Object> addContacts(@RequestBody Contacts contacts) {
        return contactsService.addContacts(contacts);
    }

    @DeleteMapping("/deleteContacts/{id}")
    @ApiOperation(value = "删除需求单位联系人", notes = "删除需求单位联系人")
    public Result<Object> deleteContacts(@PathVariable("id") String id) {
        return contactsService.deleteContacts(id);
    }

    @PostMapping("/unified")
    @ApiOperation(value = "需求单位联系人统一控制接口", notes = "需求单位联系人统一控制接口")
    public Result<Object> unified(@RequestBody UnifiedForms<Contacts> unifiedForms) {
        return contactsService.unified(unifiedForms);
    }

}